package com.leapp.sk.viewdelegate.find

import android.content.Context
import android.support.v7.app.AppCompatActivity
import android.text.TextUtils
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.NoScrollGridView
import com.example.mvp.view.SKTopBar
import com.leapp.sk.R
import com.leapp.sk.bean.BeBedTimeStoryEntity
import com.leapp.sk.ui.activity.login.PerfectUserInfoActivity
import com.leapp.sk.ui.adapter.BeBedTimeStoryAdapter

/**
 * 睡前故事视图托管类
 * @author  chaohaipeng  on 2018/8/15.
 */
class BeBedTimeStoryDelegate:BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_be_bed_time
    }

    /**
     * 初始化多列适配器
     */
    fun initMAdapter(context: Context, mlist: List<BeBedTimeStoryEntity>){
        val gv_abbt_Grid = getView<NoScrollGridView>(R.id.gv_abbt_Grid)
        val beBedTimeStoryAdapter = BeBedTimeStoryAdapter(context, mlist, false)
        gv_abbt_Grid.adapter=beBedTimeStoryAdapter
    }
    /**
     * 初始化多列适配器
     */
    fun initLAdapter(context: Context, mlist: List<BeBedTimeStoryEntity>){
        val gv_abbt_list = getView<NoScrollGridView>(R.id.gv_abbt_list)
        val beBedTimeStoryAdapter = BeBedTimeStoryAdapter(context, mlist, true)
        gv_abbt_list.adapter=beBedTimeStoryAdapter
    }

    /**
     * 设置标题栏
     */
    fun setTitle(title:String?){
        val jtb_apui= getView<SKTopBar>(R.id.jtb_abbt)
        if (!TextUtils.isEmpty(title)){
            jtb_apui.setTitle(title)
        }
        setEvent(jtb_apui)
    }

    /**
     * 设置设置事件
     */
    fun setEvent(topBar:SKTopBar){
        topBar?.inVisibleLine()
        topBar?.setEventInterface(object : SKTopBar.EventInterface{
            override fun leftOnClick() {
                getActivity<AppCompatActivity>().finish()

            }
            override fun rightOnClick() {
            }

        })
    }
}